package com.eshop.handler;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;

class ApiError
{
    private Integer status;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime timestamp;
    private String message;
    
    private ApiError() {
        this.status = 400;
        this.timestamp = LocalDateTime.now();
    }
    
    public static ApiError error(final String message) {
        final ApiError apiError = new ApiError();
        apiError.setMessage(message);
        return apiError;
    }
    
    public static ApiError error(final Integer status, final String message) {
        final ApiError apiError = new ApiError();
        apiError.setStatus(status);
        apiError.setMessage(message);
        return apiError;
    }
    
    public Integer getStatus() {
        return this.status;
    }
    
    public LocalDateTime getTimestamp() {
        return this.timestamp;
    }
    
    public String getMessage() {
        return this.message;
    }
    
    public void setStatus(final Integer status) {
        this.status = status;
    }
    
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    public void setTimestamp(final LocalDateTime timestamp) {
        this.timestamp = timestamp;
    }
    
    public void setMessage(final String message) {
        this.message = message;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof ApiError)) {
            return false;
        }
        final ApiError other = (ApiError)o;
        if (!other.canEqual(this)) {
            return false;
        }
        final Object this$status = this.getStatus();
        final Object other$status = other.getStatus();
        Label_0065: {
            if (this$status == null) {
                if (other$status == null) {
                    break Label_0065;
                }
            }
            else if (this$status.equals(other$status)) {
                break Label_0065;
            }
            return false;
        }
        final Object this$timestamp = this.getTimestamp();
        final Object other$timestamp = other.getTimestamp();
        Label_0102: {
            if (this$timestamp == null) {
                if (other$timestamp == null) {
                    break Label_0102;
                }
            }
            else if (this$timestamp.equals(other$timestamp)) {
                break Label_0102;
            }
            return false;
        }
        final Object this$message = this.getMessage();
        final Object other$message = other.getMessage();
        if (this$message == null) {
            if (other$message == null) {
                return true;
            }
        }
        else if (this$message.equals(other$message)) {
            return true;
        }
        return false;
    }
    
    protected boolean canEqual(final Object other) {
        return other instanceof ApiError;
    }
    
    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $status = this.getStatus();
        result = result * 59 + (($status == null) ? 43 : $status.hashCode());
        final Object $timestamp = this.getTimestamp();
        result = result * 59 + (($timestamp == null) ? 43 : $timestamp.hashCode());
        final Object $message = this.getMessage();
        result = result * 59 + (($message == null) ? 43 : $message.hashCode());
        return result;
    }
    
    @Override
    public String toString() {
        return "ApiError(status=" + this.getStatus() + ", timestamp=" + this.getTimestamp() + ", message=" + this.getMessage() + ")";
    }
}
